package org.zn.mvcbase.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.zn.mvcbase.response.ResponseMessage;
import org.zn.mvcbase.response.status.Success;
import org.zn.mvcbase.service.CommonCrudService;

/**
* 
* @Company OBOR
* @Author 周楠
* @Description
* 2019年7月18日
*
*/


public abstract class CommonCrudController<E,S extends CommonCrudService<E,?>> extends ResponseMessageController{

	@Autowired
	protected S commonCrudService;
	
	
	@RequestMapping("/list")
	public ResponseMessage queryList(E entity,String timeS,String timeE) {
		
		commonCrudService.querylist(getPaginationUtility(), entity,timeS,timeE);
		
		return getDataTableMessage(Success.MAINSUCCESS);
		
	}
	
	@RequestMapping("/saveupdate")
	public ResponseMessage saveupdate(E entity) {
		
		commonCrudService.saveUpdate(entity);
		
		return getMainStatus(Success.MAINSUCCESS);
		
	}
	
	@RequestMapping("/q")
	public ResponseMessage queryById(String id) {
		
		E cm=  commonCrudService.queryById(id);
		
		return getDetailMessage(Success.MAINSUCCESS, cm);
		
	}
	
	@RequestMapping("/d")
	public ResponseMessage delById(String id) {
		
		commonCrudService.delById(id);
		
		return getMainStatus(Success.MAINSUCCESS);
		
	}
	
	
	
}
